package com.sky.mapper;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /*
    * 根据菜品id查询对应的套餐id
    * */
    List<Long> getSetmealIdByDishIds(List<Long> dishIds);


    /*
    * 新增与套餐关联的菜品
    * */
    void insert(List<SetmealDish> setmealDishes);

    /*
    * 批量删除与套餐关联的菜品
    * */
    void deletes(List<Long> ids);

    /*
    * 根据id删除与套餐关联的菜品
    * */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void delete(long setmealId);

    /*
    * 根据套餐id查询与套餐关联的菜品
    * */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getById(Long id);


    /*
    * 根据菜品id查询相关的套餐
    * */
    @Select("select s.* from setmeal s left join setmeal_dish sd on s.id = sd.setmeal_id  where sd.dish_id = #{dishId}")
    List<Setmeal> getByIdDish(Long dishId);


    /*
    *
    * */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);
}
